package com.jiazhong.dijdbc;

import com.alibaba.druid.pool.DruidDataSource;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;

/**
 * @Auther:shuXin
 */
public class JdbcTest {
    @Test
    public void dataSource() {
        //最原始的方式进行赋值
        /*DruidDataSource dataSource = new DruidDataSource();
        //设置每一个信息
        dataSource.setUrl("jdbc:mysql://localhost:3306/spring_ioc");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");*/


    }

    @Test
    public void test01() {
        ApplicationContext ac = new ClassPathXmlApplicationContext("bean-jdbc.xml");
        DruidDataSource dataSource = ac.getBean(DruidDataSource.class);
        System.out.println(dataSource.getUrl());
        System.out.println(dataSource.getUsername());
    }
}
